package com.example.administrator.chinafood;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/6.
 */

public class FlMore extends Fragment {
    private int []img = {R.drawable.img_0,R.drawable.img_1,R.drawable.img_3,
            R.drawable.img_0,R.drawable.img_1,R.drawable.img_3,
            R.drawable.img_0,R.drawable.img_1,R.drawable.img_3};
    private String []txt = {"美食文化","料理知识","外国饮食",
            "甜点大全","靓汤精选","食膳养生",
            "刀工技法","装盘技巧","食材解析"};
    private List<Map<String, Object>> data_list;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fl_more,container,false);
        GridView gridView = (GridView)view.findViewById(R.id.more_gridView);
        String [] from ={"image","text"};
        getData();
        int [] to = {R.id.more_gridview_img,R.id.more_gridview_txt};
        SimpleAdapter sim_adapter = new SimpleAdapter(view.getContext(), data_list, R.layout.adapter_gridview_more, from, to);
        gridView.setAdapter(sim_adapter);
        return view;
    }

    public List<Map<String, Object>> getData(){
        data_list = new ArrayList<Map<String, Object>>();
        for(int i=0;i<img.length;i++){
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("image", img[i]);
            map.put("text", txt[i]);
            data_list.add(map);
        }
        return data_list;
    }
}
